﻿Public Class viewearnings
    Dim item As ListViewItem
    Sub listdata()
        If Not rs.EOF Then
            ListView1.Items.Clear()
            rs.MoveFirst()
            Do While Not rs.EOF
                item = ListView1.Items.Add(rs.Fields("ReceiptNo").Value)
                item.SubItems.Add(rs.Fields("date1").Value)
                item.SubItems.Add(rs.Fields("Name1").Value)
                item.SubItems.Add("Php " + FormatNumber((rs.Fields("Total").Value), 2, True, True, True))
                rs.MoveNext()

            Loop
        Else
            ListView1.Items.Clear()

        End If
        rs.Close()
        rs = Nothing
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
                Module1.connect()
                rs = New ADODB.Recordset
        rs.Open("SELECT * FROM Query6 where month(date1) = " & ComboBox1.Text & " and year(date1) = " & ComboBox2.Text & "", cn, 3, 2)
                Me.listdata()

                Module1.connect()
                rs = New ADODB.Recordset
        rs.Open("SELECT sum(total) AS total FROM Query6 where month(date1) = " & ComboBox1.Text & " and year(date1) = " & ComboBox2.Text & "", cn, 3, 2)
                If Not rs.EOF And Not rs.Fields("total").Value Is DBNull.Value Then
            Label11.Text = "Php " + FormatNumber(rs.Fields("total").Value, 2, True, True, True)
                Else
            Label11.Text = "Php " + FormatNumber("0", 2, True, True, True)
                End If
          


    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        report.Show()
        Me.Close()
    End Sub

    Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub viewearnings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ComboBox1.Text = "1"
        Dim thisyear As Integer
        thisyear = Year(Date.Today)

        Do
            ComboBox2.Items.Add(thisyear)
            thisyear = thisyear - 1
        Loop Until thisyear = 2000
        ComboBox2.Text = Year(Date.Today)
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub

    Private Sub viewearnings_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing

    End Sub
End Class